<template>
  <el-dialog
    title="修改海外操作"
    :visible.sync="centerDialogVisible"
    width="50%"
    center
  >
    <div>
      <el-row :gutter="6">
        <el-form
          ref="paramForm"
          :model="paramData"
          size="mini"
          label-width="280px"
        >
          <el-col :span="14">
            <el-form-item label="海外操作" prop="overseasOperatorId">
              <el-select
                v-model="paramData.overseasOperatorId"
                placeholder="请选择海外操作"
                clearable
                filterable
                :style="{ width: '100%' }"
              >
                <el-option
                  v-for="(k, v) in userOptions"
                  :key="v"
                  :label="userOptions[v]"
                  :value="parseInt(v)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="centerDialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="editOverseasOperatorId"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";
import { m } from "@/store/yg/common/local";

export default {
  props: {
    userOptions: {
      type: Object,
      default: function(params) {
        return {};
      }
    },
    data: {
      type: Object,
      default: function() {
        return {};
      }
    }
  },
  data() {
    return {
      centerDialogVisible: false,
      paramData: {
        id: 0,
        overseasOperatorId: ""
      }
    };
  },

  methods: {
    //直接修改渠道
    editOverseasOperatorId() {
      this.centerDialogVisible = false;
      var param = {};
      param["id"] = this.data["id"];
      param["param4"] = this.paramData.overseasOperatorId;

      ajax("editOverseasOperator", param).then(
        res => {
          if (res.code != 200) {
            if (null != res.message) {
              this.$message.error(m(res.message));
            } else {
              this.$message.error("修改失败!");
            }
          } else {
            this.$message.success("修改成功!");
            this.centerDialogVisible = false;
          }
        },
        error => {
          console.log(error);
        }
      );
    }
  },
  mounted() {
    this.paramData.overseasOperatorId = this.data["overseasOperatorId"];
  }
};
</script>

<style></style>
